Skip to content

fix(binary-codec): ensure 100% compatibility with xrpl.js reference implementation#182

Merged
GuillemGarciaDev merged 6 commits intoXRPLF:binary-codec/feat/update-definitionsfrom
XRPL-Commons:thomas/fix/binary_codec
Jan 28, 2026
Merged

fix(binary-codec): ensure 100% compatibility with xrpl.js reference implementation#182
GuillemGarciaDev merged 6 commits intoXRPLF:binary-codec/feat/update-definitionsfrom
XRPL-Commons:thomas/fix/binary_codec

Conversation

@LeJamon
Copy link

@LeJamon LeJamon commented Jan 6, 2026

fix(binary-codec): ensure 100% compatibility with xrpl.js reference implementation

Description

This PR aims to fix multiple compatibility issues between the Go binary-codec/address-codec and the xrpl.js reference implementation to ensure identical encoding/decoding behavior.

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Refactoring

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code where needed
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective
  • New and existing unit tests pass locally with my changes

Changes

  • address-codec

    • Fix decodeTag() to read 4 bytes for full 32-bit tag support (was only reading 3 bytes)
    • Fix DecodeClassicAddressToAccountID to use Base58CheckDecode for proper checksum validation
    • Fix DecodeXAddress to use Base58CheckDecode for proper checksum validation
    • Update test expectations to reflect correct error types (ErrChecksum vs ErrInvalidXAddress)
  • binary-codec

    • Correct Amount type check order (IOU before MPT) and add missing types (Int32, Int64, Number)
    • Fix Issue type ToJSON to replicate xrpl.js behaviour
    • Fix STArray to check ArrayEndMarker first in ToJSON
    • Update adjustment in Amount serialization to replicate xrpl.js behaviour
    • Update AccountID to return empty string if length = 0
    • Fix PathSet encoding to remove incorrect 20-byte padding between path steps
    • Fix PathSet ToJSON to properly combine type flags (TYPE_ACCOUNT | TYPE_CURRENCY | TYPE_ISSUER)
    • Add serializePathCurrency() to handle "XRP" currency in path steps (serializes to 20 zero bytes)
    • Fix Vector256.FromJSON to accept []interface{} in addition to []string
    • Update definitions.json with latest field definitions

Notes

These fixes were identified by creating compatibility tests using shared JSON fixtures from the xrpl.js test suite. The Go codec now produces identical binary output as the JavaScript reference implementation for all tested transaction

@GuillemGarciaDev GuillemGarciaDev changed the base branch from main to binary-codec/feat/update-definitions January 28, 2026 14:29
@GuillemGarciaDev GuillemGarciaDev merged commit 815a8b7 into XRPLF:binary-codec/feat/update-definitions Jan 28, 2026
1 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants